package Question6;

import java.applet.Applet;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Guyane
  extends Applet
{
  public Guyane()
  {
  }

  private void jbInit()
    throws Exception
  {
    this.setLayout( null );
  }

  public void init()
  {
    try
    {
      jbInit();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
  public void paint( Graphics g)
  {
    setSize(this.getWidth(),this.getHeight());
   
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    
    int xTriangleRouge[]={50,300,50};
    int yTriangleRouge[]={25,200,350};
    
    int xTriangleJaune[]={50,650,50,300};
    int yTriangleJaune[]={25,200,350,200};
    
    g2.setColor(new Color(19,103,44));
    g2.fillRect(50,25,600,325);
    g2.setColor(Color.RED);
    
    g2.fillPolygon(xTriangleRouge,yTriangleRouge,3);
   
    g2.setColor(Color.YELLOW);
    g2.fillPolygon(xTriangleJaune,yTriangleJaune,4);
  }
  public static void main(String[] args)
  {
    Guyane applet = new Guyane();
    Frame frame = new Frame();
    frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } );
    frame.add(applet, BorderLayout.CENTER);
    frame.setTitle( "Drapeau de la Guyane" );
    applet.init();
    applet.start();
    frame.setSize(700, 400);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    frame.setLocation((d.width-frameSize.width)/2, (d.height-frameSize.height)/2);
    frame.setVisible(true);
  }

  public void start()
  {
  }

  public void stop()
  {
  }

  public void destroy()
  {
  }
}
